-
Notifications
You must be signed in to change notification settings - Fork 2.6k
Add initial integration for --json=timings
behing -Zsection-timings
#15780
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
r? @weihanglo rustbot has assigned @weihanglo. Use |
src/cargo/core/compiler/timings.rs
Outdated
@@ -64,8 +64,9 @@ pub struct Timings<'gctx> { | |||
cpu_usage: Vec<(f64, f64)>, | |||
} | |||
|
|||
/// Section of compilation. | |||
struct TimingSection { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Mind moving the rename into the commit that added it so this commit can be focused just on json output?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why was this marked as resolved? I'm not seeing it resolved as requested nor an explanation for why it shouldn't happen
Ok, so based on feedback I'm fine with moving this to a fully dynamic approach. Before I do that though, do you have any suggestions on how to detect whether the timings flag should be passed to Cargo? Is there any precedent for doing something in Cargo only on the nightly channel, or more precisely only with nightly rustc? Or would you prefer that we add an unstable Cargo flag for this? |
We discussed this in today's cargo team meeting. We should not enable an unstable rustc feature implicitly but require an explicit opt-in.
|
Fair enough, I'll add an explicit feature flag then. It's true that if it was implicit, if the rustc format changes in the future, it could break nightly cargo users of |
--json=timings
--json=timings
behing -Zsection-timings
Ok, I rewrote the PR and updated the PR description. It is now gated behind an unstable |
Restructured the commits |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Update cargo 23 commits in 840b83a10fb0e039a83f4d70ad032892c287570a..9a0712751ca9444775c7352d3c942a155b656437 2025-07-30 13:59:19 +0000 to 2025-08-15 20:30:47 +0000 - Fixes error while running the cargo clippy --all-targets -- -D warning (rust-lang/cargo#15843) - Clarify that `cargo doc --no-deps` is cumulative and won’t delete prev (rust-lang/cargo#15800) - docs: Formatting and cross-linking to build-dir/target-dir docs (rust-lang/cargo#15840) - Stabilize `build.build-dir` (rust-lang/cargo#15833) - make resolve features public for cargo-as-a-library (rust-lang/cargo#15835) - chore(deps): bump slab from 0.4.10 to 0.4.11 (rust-lang/cargo#15832) - chore: remove x86_64-apple-darwin from CI and tests (rust-lang/cargo#15831) - chore(deps): update msrv (3 versions) to v1.87 (rust-lang/cargo#15819) - perf(package): Always reuse the workspace's target-dir (rust-lang/cargo#15783) - More helpful error for invalid cargo-features = [] (rust-lang/cargo#15781) - Add initial integration for `--json=timings` behing `-Zsection-timings` (rust-lang/cargo#15780) - add is_inherited methods to InheritableDependency and InheritableField (rust-lang/cargo#15828) - chore(deps): update compatible (rust-lang/cargo#15804) - docs(unstable): Link out to the Plumbing commands effort (rust-lang/cargo#15821) - chore(deps): update cargo-semver-checks to v0.43.0 (rust-lang/cargo#15825) - test(build-std): relax the thread name assertion (rust-lang/cargo#15822) - chore(deps): update msrv (1 version) to v1.89 (rust-lang/cargo#15815) - Update semver tests for 1.89 (rust-lang/cargo#15816) - Accessing each build script's `OUT_DIR` and in the correct order (rust-lang/cargo#15776) - chore: bump to 0.92.0; update changelog (rust-lang/cargo#15807) - docs: `-Zpackage-workspace` has been stabilized (rust-lang/cargo#15808) - chore(deps): update rust crate cargo_metadata to 0.21.0 (rust-lang/cargo#15795) - docs(build-rs): Fix broken intra-doc links (rust-lang/cargo#15810) r? ghost
What does this PR try to resolve?
This PR adds initial support into Cargo for JSON timing sections, implemented in rustc in rust-lang/rust#142123. This allows Cargo to read frontend/codegen/linking time from rustc, and thus reporting slightly more detailed data in the
cargo build --timings
output.The PR modifies Cargo to tell rustc to emit the section messages (
--json=...,timings
), and it adds the section timings data to the HTML table output and the JSON output. It does not yet integration different sections in the HTML unit chart (I want to do that as a follow-up).Note that the JSON timings are currently only supported on the nightly compiler (they are not stabilized). The new behavior is thus gated behing an unstable Cargo flag (
-Zsection-timings
). When the flag is unused, the HTML table should look more or less the same as before, just that the code now supports both options.How to test and review this PR?
You can run e.g. this to generate the timing report with a nightly compiler:
on some crate, e.g. ripgrep.
Tracking issue: #15817